package com.xsy.camera2.opengl

import android.content.Context
import android.util.Log
import android.view.OrientationEventListener

class MyOrientationEventListener(context: Context) : OrientationEventListener(context) {

    private var activity: MainActivity? = null
    override fun onOrientationChanged(orientation: Int) {
//        Log.e("Orientation:", "$orientation")
        if (activity != null) {
            val rotation = activity?.getRotation()
            activity?.setPhoneOrietation(rotation!!)
            activity?.calculatePreviewRotation()
        }
    }

    fun setActivity(act: MainActivity) {
        this.activity = act
    }
}